package com.monitor.system.controller;

import com.monitor.common.annotation.Log;
import com.monitor.common.core.controller.BaseController;
import com.monitor.common.core.domain.AjaxResult;
import com.monitor.common.core.page.TableDataInfo;
import com.monitor.common.enums.BusinessType;
import com.monitor.common.utils.page.PagingUtils;
import com.monitor.common.utils.poi.ExcelUtil;
import com.monitor.system.domain.ApplicationAbnormalManagement;
import com.monitor.system.service.IApplicationAbnormalManagementService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 应用异常管理Controller
 * 
 * @author monitor
 * @date 2024-06-11
 */
@RestController
@RequestMapping("/system/appManagement")
public class ApplicationAbnormalManagementController extends BaseController
{
    @Autowired
    private IApplicationAbnormalManagementService applicationAbnormalManagementService;

    /**
     * 查询应用异常管理列表
     */
    @ApiOperation("查询应用异常管理列表")
    @PreAuthorize("@ss.hasPermi('system:management:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApplicationAbnormalManagement applicationAbnormalManagement)
    {
        List<ApplicationAbnormalManagement> list = applicationAbnormalManagementService.selectApplicationAbnormalManagementList(applicationAbnormalManagement);
        return PagingUtils.createPageInfoList(list);
    }

    /**
     * 导出应用异常管理列表
     */
    @ApiOperation("导出应用异常管理列表")
    @PreAuthorize("@ss.hasPermi('system:management:export')")
    @Log(title = "应用异常管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApplicationAbnormalManagement applicationAbnormalManagement)
    {
        List<ApplicationAbnormalManagement> list = applicationAbnormalManagementService.selectApplicationAbnormalManagementList(applicationAbnormalManagement);
        ExcelUtil<ApplicationAbnormalManagement> util = new ExcelUtil<ApplicationAbnormalManagement>(ApplicationAbnormalManagement.class);
        util.exportExcel(response, list, "应用异常管理数据");
    }

    /**
     * 获取应用异常管理详细信息
     */
    @ApiOperation("获取应用异常管理详细信息")
    @PreAuthorize("@ss.hasPermi('system:management:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(applicationAbnormalManagementService.selectApplicationAbnormalManagementById(id));
    }

    /**
     * 新增应用异常管理
     */
    @ApiOperation("新增应用异常管理")
    @PreAuthorize("@ss.hasPermi('system:management:add')")
    @Log(title = "应用异常管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApplicationAbnormalManagement applicationAbnormalManagement)
    {
        return toAjax(applicationAbnormalManagementService.insertApplicationAbnormalManagement(applicationAbnormalManagement));
    }

    /**
     * 修改应用异常管理
     */
    @ApiOperation("修改应用异常管理")
    @PreAuthorize("@ss.hasPermi('system:management:edit')")
    @Log(title = "应用异常管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApplicationAbnormalManagement applicationAbnormalManagement)
    {
        return toAjax(applicationAbnormalManagementService.updateApplicationAbnormalManagement(applicationAbnormalManagement));
    }

    /**
     * 删除应用异常管理
     */
    @ApiOperation("删除应用异常管理")
    @PreAuthorize("@ss.hasPermi('system:management:remove')")
    @Log(title = "应用异常管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(applicationAbnormalManagementService.deleteApplicationAbnormalManagementByIds(ids));
    }

    /**
     * 查询应用异常管理列表
     */
    @ApiOperation("查询应用名称")
    @GetMapping("/allList")
    public TableDataInfo allList(ApplicationAbnormalManagement applicationAbnormalManagement)
    {
        startPage();
        List<ApplicationAbnormalManagement> list = applicationAbnormalManagementService.selectApplicationAbnormalManagementALLList(applicationAbnormalManagement);
        return getDataTable(list);
    }
}
